using System;
using System.Collections.Generic;

namespace SiliverlightJavascriptIntelli
{
    public static class SilverlightTypestoJavascriptConverter
    {
        public static string GetJavascriptTextForSilverlightTypes(List<SilverlightType> TypesToGenerateJavascriptFor, bool IsRunTime)
        {
            string ReturnValue = string.Empty;

            ReturnValue += JavaScriptConvertersGenerator.GetConverterJavascript(TypesToGenerateJavascriptFor);
            ReturnValue += JavascriptStaticFormats.TypeSafety;
            ReturnValue += JavascriptStaticFormats.HostTypes;
            ReturnValue += GetTypesJavascript(TypesToGenerateJavascriptFor, IsRunTime);

            return ReturnValue;
        }

        private static string GetTypesJavascript(List<SilverlightType> TypesToGenerateJavascriptFor, bool IsRunTime)
        {
            string ReturnValue = string.Empty;

            foreach (SilverlightType silverlightTypeToGetJavascriptFor in TypesToGenerateJavascriptFor)
            {
                ReturnValue += silverlightTypeToGetJavascriptFor.ToJavascript(IsRunTime);
            }


            return ReturnValue;
        }

        public static string GetJavascriptTextForSilverlightTypes(List<SilverlightType> TypesToGenerateJavascriptFor)
        {
            return GetJavascriptTextForSilverlightTypes(TypesToGenerateJavascriptFor, false);
        }
    }
}